<?php defined('SYSPATH') OR die('No direct access allowed.');

class Controller_Via extends Controller
{
	private $via_model;
	private $list_view;
	private $create_view;
	private $vias_list=array();
	
  public function __construct(Kohana_Request $request, Kohana_Response $response)
  {
    parent::__construct($request, $response);
		$this->via_model     = new Model_Via;
		$this->list_view     = new View('via');
		$this->create_view     = new View('create_via');
	}
	
	
	public function action_index(){
		$this->show_vias_list();
	}

	private function show_vias_list()
	{
		$vias_list = $this->via_model->get_list();
		$this->list_view->set('vias_list',$vias_list);
		$this->response->body($this->list_view);
	}

	public function show_create_editor(){
		$this->create_view->set($key)
		$this->create_view->render(TRUE);
	}
	
	public function create(){
		$via_data=array(
			codvia	=> $this->input>post('codvia'),
			tipvia	=> $this->input>post('tipvia'),
			desvia	=> $this->input>post('desvia')
		);
		$this->via_model->create($via_data);		
		url::redirect('via');
	}
}
?>
